package com.yugao.fintech.antelope.system.controller;

import com.yugao.fintech.antelope.base.ram.ActionType;
import com.yugao.fintech.antelope.base.ram.RamResource;
import com.yugao.fintech.antelope.system.model.rqrs.menu.MenuSceneResp;
import com.yugao.fintech.antelope.system.model.rqrs.menu.MenuSceneSaveReq;
import com.yugao.fintech.antelope.system.model.rqrs.menu.MenuSceneUpdateReq;
import com.yugao.fintech.antelope.system.model.rqrs.menu.SceneListReq;
import com.yugao.fintech.antelope.system.service.SysMenuSceneService;
import com.yugao.fintech.framework.core.response.Resp;
import io.swagger.annotations.Api;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "菜单场景")
@RestController
@RequestMapping("/menuScene")
public class MenuSceneController {
    @Autowired
    private SysMenuSceneService sysMenuSceneService;

    /**
     * 分页 场景
     */
    @GetMapping("/listScene")
    @RamResource(action = "sys:menuScene:query", name = "查询菜单场景", type = ActionType.READ)
    public Resp<List<MenuSceneResp>> listScene(@Validated SceneListReq query) {
        return Resp.ok(sysMenuSceneService.listScene(query));
    }
  
    /**
     * 保存 场景
     */
    @PostMapping("/saveScene")
    @RamResource(action = "sys:menuScene:save", name = "保存菜单场景", type = ActionType.WRITE)
    public Resp<?> saveScene(@Validated @RequestBody MenuSceneSaveReq req) {
        return Resp.ok(sysMenuSceneService.saveScene(req));
    }
  
    /**
     * 更新 场景
     */
    @PostMapping("/updateScene")
    @RamResource(action = "sys:menuScene:update", name = "更新菜单场景", type = ActionType.WRITE)
    public Resp<?> updateSceneById(@Validated @RequestBody MenuSceneUpdateReq req) {
        return Resp.ok(sysMenuSceneService.updateSceneById(req));
    }
  
    /**
     * 批量删除 场景
     */
    @DeleteMapping("/batchDeleteScene")
    @RamResource(action = "sys:menuScene:delete", name = "删除菜单场景", type = ActionType.WRITE)
    public Resp<?> deleteBatch(@RequestParam(value = "ids") List<Long> ids) {
        return Resp.ok(sysMenuSceneService.deleteSceneByIds(ids));
    }
  
    /**
     * 删除 场景
     */
    @DeleteMapping("/deleteScene")
    @RamResource(action = "sys:menuScene:delete", name = "删除菜单场景", type = ActionType.WRITE)
    public Resp<?> delete(@RequestParam(value = "id") Long id) {
        return Resp.ok(sysMenuSceneService.deleteSceneById(id));
    }
}
